package cn.itcast.rnk.oop;

import java.util.Iterator;

public class DataStructure {
	private static final int SIZE =15;
	private int[] arrOfIndex =new int[SIZE];
	public DataStructure(){
		for (int a = 0; a < SIZE; a++) {
			arrOfIndex[a]=a;
		}
	}

	private void printEven() {

		EvenIterator iterator = new EvenIterator();
		while (iterator.hasNext()) {
			int integer = (Integer) iterator.next();
			System.out.println(integer);

		}
		System.out.println("\n");
	}

	interface DataStructureIterator  extends Iterator<Integer>{};
	private class EvenIterator implements DataStructureIterator{
		private int nextIndex=0;
		@Override
		public boolean hasNext() {
			// TODO Auto-generated method stub
			return (nextIndex<=SIZE-1);
		}

		@Override
		public Integer next() {
			// TODO Auto-generated method stub
			Integer retValue  = Integer.valueOf(arrOfIndex[nextIndex]);
			nextIndex+=2;
			return retValue ;
		}

	}

	public static void main(String[] args) {
		DataStructure ds = new DataStructure();
		ds.printEven();
	}



}